<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>类别管理</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css" />
<script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
</head>
<body>
		<jsp:include page="header.jsp"></jsp:include>
		
		<jsp:include page="category-search.jsp"></jsp:include>
		
		<!-- 内容区域 -->
		<div class="container-fluid" style="margin: 30px;">
			<div class="col-xs-8" style="border: 1px solid gray;border-radius: 8px;height: 500px;">
				<!-- 类别列表 -->
				<div>
					<h4>类别列表</h4>
					<table class="table">
						<thead>
							<tr>
								<th>类别id</th>
								<th>类别名称</th>
								<th>描述</th>
								<th colspan="2" style="width: 20%;">操作</th>
							</tr>
						</thead>
						<tbody>
						<c:forEach items="${pageInfo.list}" var="category">
							<tr>
								<td>${category.categoryId}</td>
								<td>${category.categoryName}</td>
								<td>${category.categoryDesc}</td>
								<td><button type="button" class="btn btn-primary" onclick="location.href='${pageContext.request.contextPath}/category/findById.do?categoryId=${category.categoryId}'">更新</button></td>
								<td><button type="button" class="btn btn-danger" onclick="location.href='${pageContext.request.contextPath}/category/delete.do?categoryId=${category.categoryId}'">删除</button></td>
							</tr>
						</c:forEach>
						</tbody>
					</table>
				</div>
				
				<!-- 分页 -->
			<div class="col-md-offset-5">
				<nav aria-label="Page navigation">
				<ul class="pagination">
					<c:if test="${pageInfo.pageNum==1}">
						<li class="disabled"><a href="#" aria-label="Previous"> <span
							aria-hidden="true">&laquo;</span>
					</a></li>
					</c:if>
					
					<c:if test="${pageInfo.pageNum!=1}">
						<li><a href="${pageContext.request.contextPath}/category/findAll.do?pageNum=${pageInfo.pageNum-1}&condition=${condition}" aria-label="Previous"> <span
							aria-hidden="true">&laquo;</span>
					</a></li>
					</c:if>

					<c:forEach begin="1" end="${pageInfo.pages}" var="i">
						<c:if test="${pageInfo.pageNum!=i}">
							<li><a
								href="${pageContext.request.contextPath}/category/findAll.do?pageNum=${i}&condition=${condition}">${i}</a></li>
						</c:if>
						<c:if test="${pageInfo.pageNum==i}">
							<li class="active"><a
								href="${pageContext.request.contextPath}/category/findAll.do?pageNum=${i}&condition=${condition}">${i}</a></li>
						</c:if>
					</c:forEach>
					
					<c:if test="${pageInfo.pageNum==pageInfo.pages}">
						<li class="disabled"><a aria-label="Next"> <span
							aria-hidden="true">&raquo;</span>
					</a></li>
					</c:if>
					
					<c:if test="${pageInfo.pageNum!=pageInfo.pages}">
						<li><a href="${pageContext.request.contextPath}/category/findAll.do?pageNum=${pageInfo.pageNum+1}&condition=${condition}" aria-label="Next"> <span
							aria-hidden="true">&raquo;</span>
					</a></li>
					</c:if>
				</ul>
				 <h4> 共${pageInfo.pages}条记录，共${pageInfo.total}页</h4>
			</nav>
			</div>

			</div>
			

			<div class="col-xs-1"></div>
			<div class="col-xs-3" style="border: 1px solid gray;height: 500px;border-radius: 8px;">
				<div style="height: 600px;">
					<!-- 添加类别 -->
					<form method="post" action="${pageContext.request.contextPath}/category/save.do">
						<h4>添加类别</h4>
						<div class="form-group">
							<label>类别名称</label>
							<input type="text" class="form-control" placeholder="类别名称" name="categoryName">
						</div>
						<div class="form-group">
							<label>类别描述</label>
							<textarea rows="5" class="form-control" name="categoryDesc"></textarea>
						</div>

						<button type="submit" class="btn btn-primary center-block">添加</button>
					</form>
				</div>
			</div>
			</div>
	</body>
</html>
